
package com.shangsi.controller;

import com.shangsi.service.ShoppingService;
import io.seata.spring.annotation.GlobalLock;
import io.seata.spring.annotation.GlobalTransactional;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

/**
 * @author dzd
 * @date 2021-12-19
 */
@RestController
public class ShoppingController {

    @Resource
    ShoppingService shoppingService;

    @GlobalTransactional
    @GlobalLock
    @PostMapping("shopping")
    public Boolean shopping(@RequestParam("userId") Integer userId,
                            @RequestParam("amount") Integer amount,
                            @RequestParam("count") Integer count,
                            @RequestParam("remark") String remark){

       return shoppingService.shopping(userId,amount,count,remark);
    }
}
